package com.example.leetcode.sort;

import java.util.*;

/**
 * @ClassName Solution_251
 * @Description TODO
 * @Author liuzhihui
 * @Date 26/4/2021 下午 10:57
 * @Version 1.0
 **/
public class Solution_251 {
    public static void main(String[] args) {
        Map<Integer,Integer> map = new HashMap();
        PriorityQueue<Integer> queue = new PriorityQueue<>((o1, o2) -> map.get(o2) - map.get(o1));

    }

    private int  findKthLargest1(int[] nums, int k) {
        PriorityQueue<Integer> priorityQueue = new PriorityQueue();

        for (int i = 0; i < nums.length; i++) {
            priorityQueue.add(nums[i]);
            // 当queue的大小大于k,每次弹出栈顶的最小元素
            if (priorityQueue.size() > k){
                priorityQueue.poll();
            }
        }
        return priorityQueue.peek();
    }
}
